<!--
 * @Author: your name
 * @Date: 2022-04-06 11:06:07
 * @LastEditTime: 2023-07-05 14:04:28
 * @LastEditors: Please set LastEditors
 * @Description: 
      路由方式
      在页面下使用路由方式跳转审批同意、拒绝页面 带参:approveType taskId
      this.$router.push({ path: '/approval', query: {approveType:1,taskId:"4555"} })
      approveType:审批类型 0 同意，1拒绝
      taskId：任务ID
 * @FilePath: \jk_one-stop_cloud_mobile_v1.0\src\views\approval\approval.vue
-->
<template>
  <div class="approval">
    <Navbar :appTitle="title" :rtitle="rtitle" :rname="rname" />
    <van-cell-group inset>
      <van-field
        v-model="formData.option"
        rows="6"
        autosize
        label="审批意见"
        type="textarea"
        placeholder="请输入审批意见"
        maxlength="500"
      />
    </van-cell-group>
    <upload class="fileclass" iconType="fj" @fileChange="fileChange" :fileIds="fileIds" 
    :showUpload="true"></upload>
    <div class="search-bottom">
      <!-- <span class="btncancel" @click="cancel">取消</span> -->
      <span class="btnconfirm" @click="confirm">{{title}}</span>
    </div>
  </div>
</template>

<script>
import { getAction, uploadAction, postAction,putAction} from "@/api/manage";
import Navbar from "@/components/navBar/navBar_right";
import upload from "@/components/upload/upload";
export default {
  computed: {},
  components: { Navbar, upload },
  data() {
    return {
      title: "确认拒绝",
      rtitle: "",
      type: 0, //0同意，1拒绝
      rname: "", //search
      listUrl: "sys/dict/list", //列表接口
      fileIds:"",
      formData: {},
      url: {
        agree: "/proc/operate/agree",
        refuse: "/proc/operate/refuse",
      },
    };
  },
  created() {
    if (this.$route.query.approveType == "0") {
      this.title = "确认拒绝";
      this.type=1
    } else if (this.$route.query.approveType == "1") {
      this.title = "确认同意";
      this.type=0
    }
    this.formData.taskId=this.$route.query.taskId
  },
  methods: {
    fileChange(ids){
    console.log(ids)  
    this.formData.attachment=ids
    },
    confirm(){
      console.log(this.formData, 'this.formData')
      // this.loading=true
      putAction(this.type === 0 ? this.url.agree : this.url.refuse, this.formData).then((res) => {
        console.log(res, 'res')
        if (res.code === 200) {
          this.$toast(res.message)
          this.formData = {}
          // localStorage.setItem("approval", "success");
           this.$router.go(-2);
         
        } else {
          this.$toast(res.message)
          // localStorage.setItem("approval", "fail");
          this.$router.go(-2);
        }
      })
    }
  },
  watch: {},
};
</script>

<style lang="scss" scoped>
.approval {
  .fileclass{
    margin-top: 0.1rem;
  }
  .search-bottom {
    height: 0.5rem;
    width: 100%;
    background: #ffffff;
    // background: red;
    display: flex;
    // justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0px;
    padding: 0.11rem;
    .btnconfirm {
      display: block;
       width: 100%;
      // width: 1.72rem;
      height: 0.39rem;
      background: #1890ff;
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;


      font-size: 0.16rem;
      font-family: PingFang SC;
      font-weight: 500;
      color: #FFFFFF;
      // line-height: 0.05rem;
    }
    // .btncancel {
    //   width: 1.72rem;
    //   height: 0.39rem;
    //   background: #f6f6f6;
    //   border: 0.01px solid rgba(25, 31, 37, 0.12);
    //   border-radius: 0rem;
    //   text-align: center;
    //   line-height: 0.39rem;
    // }
  }
}
</style>
